﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using YmSoft.Kblog.BLL;
using YmSoft.Kblog.Model;


namespace YmSoft.Kblog.Web.Handler
{
    /// <summary>
    /// LoginSystem 的摘要说明
    /// </summary>
    public class LoginSystem : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            try
            {
                YmSoft.Kblog.Utility.GetMd5 md5 = new Utility.GetMd5();
                string _loginname = context.Request.Form["LoginName"].ToString();
                string _loginpwd = context.Request.Form["LoginPwd"].ToString();
                LoginManager login = new LoginManager();
                if (login.GetLoginInfoByLoginPass(_loginname.Trim(), md5.MD5(_loginpwd.Trim())) != null)
                {
                    context.Response.Write("{\"state\":true}");
                }
                else
                {
                    context.Response.Write("{\"state\":false}");
                }
            }
            catch (Exception)
            {
                context.Response.Write("{\"state\":false}");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}